﻿/*
版权所有：版权所有(C) 2010，刘建新
文件编号：M01_BaseTemplates.cs
文件名称：BaseTemplates.cs
系统编号：Z0003007
系统名称：通用办公系统
模块编号：M01
模块名称：信息发布
设计文档：IOA_M01信息发布XDE建模.mdx
完成日期：2010/12/20
作　　者：
内容摘要：表[Base_Templates]对应的实体类
*/

using System;
using System.Collections;
using System.Data;


namespace Eis51.CampanyCMS.Model.BaseInfoMng
{
		/// <summary>
		/// 类 编 号：
		/// 类 名 称：BaseTemplates
		/// 内容摘要：
		/// </summary>
		
		[Serializable]
		public class BaseTemplates : BaseModel
		{
		#region 自动生成代码
		
			#region 重载Equals/GetHashCode
			/// <summary>
			/// 重载Equals			
			/// </summary>
			public override bool Equals (Object obj)
			{
				if (obj != null && obj is BaseTemplates)
				{
					if (obj == this)
						return true;
					BaseTemplates castObj = (BaseTemplates)obj; 
					
					if (!this.m_TemplateId.Equals(castObj.TemplateId))
						return false;
						
					if (!this.m_TemplateName.Equals(castObj.TemplateName))
						return false;
						
					if (!this.m_TemplateFloder.Equals(castObj.TemplateFloder))
						return false;
						
					if (!this.m_TemplateThumbnailPath.Equals(castObj.TemplateThumbnailPath))
						return false;
						
					if (!this.m_Desc.Equals(castObj.Desc))
						return false;
						
					if (!this.m_CreateDate.Equals(castObj.CreateDate))
						return false;
						
					if (!this.m_CreateBy.Equals(castObj.CreateBy))
						return false;
						
					if (!this.m_LasteUpdateBy.Equals(castObj.LasteUpdateBy))
						return false;
						
					if (!this.m_LimitNum.Equals(castObj.LimitNum))
						return false;
						
					return true;
				}
				return false;
			}
			
			/// <summary>
			/// 重载GetHashCode
			/// </summary>
			public override int GetHashCode()
			{
					int hash = 0;					
					
					hash = hash <<  8;
					if ((object)m_TemplateId != null)
					{
						hash = hash ^ m_TemplateId.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_TemplateName != null)
					{
						hash = hash ^ m_TemplateName.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_TemplateFloder != null)
					{
						hash = hash ^ m_TemplateFloder.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_TemplateThumbnailPath != null)
					{
						hash = hash ^ m_TemplateThumbnailPath.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_Desc != null)
					{
						hash = hash ^ m_Desc.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_CreateDate != null)
					{
						hash = hash ^ m_CreateDate.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_CreateBy != null)
					{
						hash = hash ^ m_CreateBy.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_LasteUpdateBy != null)
					{
						hash = hash ^ m_LasteUpdateBy.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_LimitNum != null)
					{
						hash = hash ^ m_LimitNum.GetHashCode();
					}
						
					return hash; 
			}
			#endregion
			
			public BaseTemplates()
			{
				MarkNew();
			}						
			
			public BaseTemplates GetOldValue()
			{
				return OldValue as BaseTemplates;
			}
		
		#region TemplateId属性
			private int m_TemplateId = 0;
			/// <summary>
			/// 属性名称： TemplateId
			/// 内容摘要： DB列名：Template_ID[]
			///            DB类型：int
			/// </summary>
			public int TemplateId
			{
				get
					{
						return m_TemplateId;
					}
				set
					{
						if (m_TemplateId as object == null || !m_TemplateId.Equals(value))
						{
							m_TemplateId = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region TemplateName属性
			private string m_TemplateName = String.Empty;
			/// <summary>
			/// 属性名称： TemplateName
			/// 内容摘要： DB列名：Template_Name[]
			///            DB类型：string
			/// </summary>
			public string TemplateName
			{
				get
					{
						return m_TemplateName;
					}
				set
					{
						if (m_TemplateName as object == null || !m_TemplateName.Equals(value))
						{
							m_TemplateName = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region TemplateFloder属性
			private string m_TemplateFloder = String.Empty;
			/// <summary>
			/// 属性名称： TemplateFloder
			/// 内容摘要： DB列名：Template_Floder[]
			///            DB类型：string
			/// </summary>
			public string TemplateFloder
			{
				get
					{
						return m_TemplateFloder;
					}
				set
					{
						if (m_TemplateFloder as object == null || !m_TemplateFloder.Equals(value))
						{
							m_TemplateFloder = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region TemplateThumbnailPath属性
			private string m_TemplateThumbnailPath = String.Empty;
			/// <summary>
			/// 属性名称： TemplateThumbnailPath
			/// 内容摘要： DB列名：Template_Thumbnail_path[]
			///            DB类型：string
			/// </summary>
			public string TemplateThumbnailPath
			{
				get
					{
						return m_TemplateThumbnailPath;
					}
				set
					{
						if (m_TemplateThumbnailPath as object == null || !m_TemplateThumbnailPath.Equals(value))
						{
							m_TemplateThumbnailPath = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region Desc属性
			private string m_Desc = String.Empty;
			/// <summary>
			/// 属性名称： Desc
			/// 内容摘要： DB列名：Desc[]
			///            DB类型：string
			/// </summary>
			public string Desc
			{
				get
					{
						return m_Desc;
					}
				set
					{
						if (m_Desc as object == null || !m_Desc.Equals(value))
						{
							m_Desc = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region CreateDate属性
			private DateTime m_CreateDate = new DateTime(1900,1,1);
			/// <summary>
			/// 属性名称： CreateDate
			/// 内容摘要： DB列名：Create_Date[]
			///            DB类型：DateTime
			/// </summary>
			public DateTime CreateDate
			{
				get
					{
						return DateTime.Parse(m_CreateDate.ToString("yyyy-MM-dd HH:mm:ss"));
					}
				set
					{
						if (m_CreateDate as object == null || !m_CreateDate.Equals(value))
						{
							m_CreateDate = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region CreateBy属性
			private string m_CreateBy = String.Empty;
			/// <summary>
			/// 属性名称： CreateBy
			/// 内容摘要： DB列名：Create_By[]
			///            DB类型：string
			/// </summary>
			public string CreateBy
			{
				get
					{
						return m_CreateBy;
					}
				set
					{
						if (m_CreateBy as object == null || !m_CreateBy.Equals(value))
						{
							m_CreateBy = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region LasteUpdateBy属性
			private string m_LasteUpdateBy = String.Empty;
			/// <summary>
			/// 属性名称： LasteUpdateBy
			/// 内容摘要： DB列名：Laste_update_by[]
			///            DB类型：string
			/// </summary>
			public string LasteUpdateBy
			{
				get
					{
						return m_LasteUpdateBy;
					}
				set
					{
						if (m_LasteUpdateBy as object == null || !m_LasteUpdateBy.Equals(value))
						{
							m_LasteUpdateBy = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region LimitNum属性
			private int m_LimitNum = 0;
			/// <summary>
			/// 属性名称： LimitNum
			/// 内容摘要： DB列名：Limit_Num[]
			///            DB类型：int
			/// </summary>
			public int LimitNum
			{
				get
					{
						return m_LimitNum;
					}
				set
					{
						if (m_LimitNum as object == null || !m_LimitNum.Equals(value))
						{
							m_LimitNum = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region static CreateDataTable/FillDataRow/DataRow2Obj/Dt2Objs/FillDataTable
			/// <summary>
			/// 得到实体对应的DataTable
			/// </summary>
			/// <param name="tableName">表名</param>
			/// <param name="cne">列名映射选择:DB列名或属性名</param>
			/// <returns>生成的DataTable</returns>
			static public DataTable CreateDataTable(string tableName,ColumnNameEnum cne)
			{
				DataTable dtResult = new DataTable(tableName);
			
				if (cne == ColumnNameEnum.DBName)
				{
					dtResult.Columns.Add(new DataColumn("Template_ID",typeof(int)));
					dtResult.Columns.Add(new DataColumn("Template_Name",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Template_Floder",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Template_Thumbnail_path",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Desc",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Create_Date",typeof(DateTime)));
					dtResult.Columns.Add(new DataColumn("Create_By",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Laste_update_by",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Limit_Num",typeof(int)));
				}
				else if (cne == ColumnNameEnum.PropertyName)
				{
					dtResult.Columns.Add(new DataColumn("TemplateId",typeof(int)));
					dtResult.Columns.Add(new DataColumn("TemplateName",typeof(string)));
					dtResult.Columns.Add(new DataColumn("TemplateFloder",typeof(string)));
					dtResult.Columns.Add(new DataColumn("TemplateThumbnailPath",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Desc",typeof(string)));
					dtResult.Columns.Add(new DataColumn("CreateDate",typeof(DateTime)));
					dtResult.Columns.Add(new DataColumn("CreateBy",typeof(string)));
					dtResult.Columns.Add(new DataColumn("LasteUpdateBy",typeof(string)));
					dtResult.Columns.Add(new DataColumn("LimitNum",typeof(int)));
				}
				return dtResult;
			}
			
			/// <summary>
			/// 得到实体对应的DataTable
			/// </summary>
			/// <param name="cne">列名映射选择:DB列名或属性名</param>
			/// <returns>生成的DataTable</returns>
			static public DataTable CreateDataTable(ColumnNameEnum cne)
			{
				return CreateDataTable(null,cne);
			}

			/// <summary>
			/// 得到实体对应的DataTable(默认列名映射为属性名)
			/// </summary>
			/// <returns>生成的DataTable</returns>
			static public DataTable CreateDataTable()
			{
				return CreateDataTable(ColumnNameEnum.PropertyName);
			}
			
			/// <summary>
			/// 用当前对象值填充DaraRow
			/// </summary>
			/// <param name="dr">由CreateTable生成的DataTable通过NewRow得到的DataRow对象</param>
			/// <param name="cne">dr的列名映射方式:DB列名或属性名</param>
			public void FillDataRow(DataRow dr,ColumnNameEnum cne)
			{
				if (dr == null)
				{
					throw new ArgumentNullException("dr");
				}
				if (ColumnNameEnum.DBName == cne)
				{
					dr["Template_ID"] = this.TemplateId;
					dr["Template_Name"] = this.TemplateName;
					dr["Template_Floder"] = this.TemplateFloder;
					dr["Template_Thumbnail_path"] = this.TemplateThumbnailPath;
					dr["Desc"] = this.Desc;
					dr["Create_Date"] = this.CreateDate;
					dr["Create_By"] = this.CreateBy;
					dr["Laste_update_by"] = this.LasteUpdateBy;
					dr["Limit_Num"] = this.LimitNum;
				}
				else if (ColumnNameEnum.PropertyName == cne)
				{
					dr["TemplateId"] = this.TemplateId;
					dr["TemplateName"] = this.TemplateName;
					dr["TemplateFloder"] = this.TemplateFloder;
					dr["TemplateThumbnailPath"] = this.TemplateThumbnailPath;
					dr["Desc"] = this.Desc;
					dr["CreateDate"] = this.CreateDate;
					dr["CreateBy"] = this.CreateBy;
					dr["LasteUpdateBy"] = this.LasteUpdateBy;
					dr["LimitNum"] = this.LimitNum;					
				}
			}
			
			/// <summary>
			/// 用当前对象值填充DaraRow(默认列名映射为属性名)
			/// </summary>
			/// <param name="dr">由CreateTable生成的DataTable通过NewRow得到的DataRow对象</param>
			public void FillDataRow(DataRow dr)
			{
				this.FillDataRow(dr,ColumnNameEnum.PropertyName);
			}
			
			/// <summary>
			/// 将DataRow转换成BaseTemplates对象
			/// </summary>
			/// <param name="dr">由CreateTable生成的DataTable通过NewRow得到的DataRow对象</param>
			/// <param name="cne">dr的列名映射方式:DB列名或属性名</param>
			/// <returns>BaseTemplates对象</returns>
			public static BaseTemplates Dr2Obj(DataRow dr,ColumnNameEnum cne)
			{
				if (dr == null)
				{
					throw new ArgumentNullException("dr");
				}
				BaseTemplates obj = new BaseTemplates();
				if (ColumnNameEnum.DBName == cne)
				{
					obj.TemplateId = (dr["Template_ID"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["Template_ID"],typeof(int));
					obj.TemplateName = (dr["Template_Name"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Template_Name"],typeof(string));
					obj.TemplateFloder = (dr["Template_Floder"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Template_Floder"],typeof(string));
					obj.TemplateThumbnailPath = (dr["Template_Thumbnail_path"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Template_Thumbnail_path"],typeof(string));
					obj.Desc = (dr["Desc"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Desc"],typeof(string));
					obj.CreateDate = (dr["Create_Date"] == Convert.DBNull) ? new DateTime(1900,1,1)  : (DateTime)Convert.ChangeType(dr["Create_Date"],typeof(DateTime));
					obj.CreateBy = (dr["Create_By"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Create_By"],typeof(string));
					obj.LasteUpdateBy = (dr["Laste_update_by"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Laste_update_by"],typeof(string));
					obj.LimitNum = (dr["Limit_Num"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["Limit_Num"],typeof(int));
				}
				else if (ColumnNameEnum.PropertyName == cne)
				{
					obj.TemplateId = (dr["TemplateId"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["TemplateId"],typeof(int));
					obj.TemplateName = (dr["TemplateName"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["TemplateName"],typeof(string));
					obj.TemplateFloder = (dr["TemplateFloder"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["TemplateFloder"],typeof(string));
					obj.TemplateThumbnailPath = (dr["TemplateThumbnailPath"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["TemplateThumbnailPath"],typeof(string));
					obj.Desc = (dr["Desc"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Desc"],typeof(string));
					obj.CreateDate = (dr["CreateDate"] == Convert.DBNull) ? new DateTime(1900,1,1)  : (DateTime)Convert.ChangeType(dr["CreateDate"],typeof(DateTime));
					obj.CreateBy = (dr["CreateBy"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["CreateBy"],typeof(string));
					obj.LasteUpdateBy = (dr["LasteUpdateBy"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["LasteUpdateBy"],typeof(string));
					obj.LimitNum = (dr["LimitNum"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["LimitNum"],typeof(int));		
				}
				
				return obj;
			}
			
			/// <summary>
			/// 将DataRow转换成BaseTemplates对象(默认列名映射为属性名)
			/// </summary>
			/// <returns>BaseTemplates对象</returns>
			public static BaseTemplates Dr2Obj(DataRow dr)
			{
				return Dr2Obj(dr,ColumnNameEnum.DBName);
			}
			
			/// <summary>
			/// 将DataTabe转换成的BaseTemplates对象集合
			/// </summary>
			/// <param name="dt">由CreateTable生成的DataTable</param>
			/// <param name="cne">dt的列名映射方式:DB列名或属性名</param>
			/// <returns>BaseTemplates对象的集合</returns>
			public static IList Dt2Objs(DataTable dt,ColumnNameEnum cne)
			{
				if (dt == null)
				{
					throw new ArgumentNullException("dt");
				}
				
				ArrayList alResult = new ArrayList();
				
				foreach(DataRow dr in dt.Rows)
				{
					alResult.Add(Dr2Obj(dr,cne));
				}
				
				return alResult;
			}

			/// <summary>
			/// 将DataTabe转换成的BaseTemplates对象集合(默认列名映射为属性名)
			/// </summary>
			/// <param name="dt">由CreateTable生成的DataTable</param>
			/// <returns>BaseTemplates对象的集合</returns>
			public static IList Dt2Objs(DataTable dt)
			{
				return Dt2Objs(dt,ColumnNameEnum.PropertyName);
			}
			
			/// <summary>
			/// 用objs的BaseTemplates对象集合填充DataTable
			/// </summary>
			/// <param name="dt">由CreateTable生成的DataTable</param>
			/// <param name="objs">BaseTemplates对象集合</param>
			/// <param name="cne">dt的列名映射方式:DB列名或属性名</param>
			public static void FillDataTable(DataTable dt,IList objs,ColumnNameEnum cne)
			{
				if (dt == null)
				{
					throw new ArgumentNullException("dt");
				}
				if (objs == null)
				{
					throw new ArgumentNullException("objs");
				}
				
				foreach(BaseTemplates obj in objs)
				{
					DataRow dr = dt.NewRow();
					obj.FillDataRow(dr,cne);
					dt.Rows.Add(dr);
				}
			}

			/// <summary>
			/// 用objs的BaseTemplates对象集合填充DataTable(默认列名映射为属性名)
			/// </summary>
			/// <param name="dt">由CreateTable生成的DataTable</param>
			/// <param name="objs">BaseTemplates对象集合</param>
			public static void FillDataTable(DataTable dt,IList objs)
			{
				FillDataTable(dt,objs,ColumnNameEnum.PropertyName);
			}
		#endregion
		
		/// <summary>
		/// 取消编辑,恢复到上次有效调用BeginEdit前的状态,并清空保留值
		/// </summary>
		public override void CancelEdit()
		{
			BaseTemplates old = this.OldValue as BaseTemplates;
			if (old != null)
			{
					this.TemplateId = old.TemplateId;
					this.TemplateName = old.TemplateName;
					this.TemplateFloder = old.TemplateFloder;
					this.TemplateThumbnailPath = old.TemplateThumbnailPath;
					this.Desc = old.Desc;
					this.CreateDate = old.CreateDate;
					this.CreateBy = old.CreateBy;
					this.LasteUpdateBy = old.LasteUpdateBy;
					this.LimitNum = old.LimitNum;				
				this.OldValue = null;
			}
		}
		
		
		
		
		#region BaseTemplates实体的内部Key类
			/// <summary>
			/// BaseTemplates实体的Key类
			/// </summary>
			public sealed class Key
			{
		
				private int m_TemplateId;
				public int TemplateId
				{
 					get 
					{ 
						 return m_TemplateId; 
					}
					set 
					{ 
						m_TemplateId = value;
					}
				}
		
				public Key(int pTemplateId)
				{
					m_TemplateId=pTemplateId;

				}
			}
		#endregion
			/// <summary>
			/// 得到实体BaseTemplates的PK
			/// </summary>
			public Key GetKey()
			{
				return new Key(TemplateId);				
			}
			
				
		#endregion
	}
}
